import 'package:flutter/cupertino.dart';
import 'package:flutter_demo/pages/squadron_worker_test/task/generated/task_demo_1.activator.g.dart';
import 'package:squadron/squadron.dart';
import 'package:squadron/squadron_annotations.dart';

part 'generated/task_demo_1.worker.g.dart';

@SquadronService()
class TaskDemo1 {
  //call dart compile js .\lib\src\pi-digits\browser\pi_digits_worker.dart -o .\web\workers\pi_digits_worker.dart.js -m
  //dart compile js .\lib\pages\squadron_worker_test\task\generated\task_demo_1.web.g.dart -o \pages\squadron_worker_test\task\generated\task_demo_1.web.g.dart.js -m

  @SquadronMethod()
  Future<int> calcTest1(String? name)async {
    debugPrint("[Thread],calcTest1,开始执行");
    // 模拟计算

    int result = 1;
    for(int i=0;i<1000000000;i++){
      result = result + i;
    }
    debugPrint("[Thread],calcTest1,结束执行");
    return result;
  }
}
